package net.huashitong.user.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.user.entity.TemporaryMessage;
import net.huashitong.user.filter.MessageFilter;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class TemporaryMessageDao extends StringDao<TemporaryMessage> {
     public List<TemporaryMessage> getTemporaryMessageInfo(MessageFilter filter){
         GenericQuery query = createQuery("obj");
         if(StringUtils.isNotBlank(filter.getType())){
             query.append(" and obj.type =:type").setParam("type", filter.getType());
         }
         query.append(" ORDER BY sys_id desc");
         return query.listResult(filter);
     }
     public List<TemporaryMessage> getTemporaryMessageInfos(){
         GenericQuery query = createQuery("obj");
         query.append(" and obj.type =:type").setParam("type", "2");
         query.append(" ORDER BY sys_id desc");
         return query.listResult();
     }
    public List<TemporaryMessage> getMessageModels(String projectName,String nodeId,String phone){
        GenericQuery query = createQuery("obj");
        query.append(" and obj.projectName =:projectName").setParam("projectName", projectName);
        query.append(" and obj.nodeId =:nodeId").setParam("nodeId", nodeId);
        query.append(" and obj.phone =:phone").setParam("phone", phone);
        return query.listResult();
    }
}

